package locations.actions;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import locations.dao.DAOFactory;
import locations.dao.PacientDAO;
import locations.model.Pacient;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;



public class SavePacientAction extends ActionSupport implements ModelDriven<Pacient>, ServletRequestAware, ServletResponseAware  {
	
		private static final long serialVersionUID = -8124967730231198191L;
		
		private HttpServletRequest request; 
		private HttpServletResponse response; 
		private Pacient pacient = new Pacient();
		
		public String execute(){
			PacientDAO dao = DAOFactory.getPacientDAO();
			dao.save(this.pacient);
			return SUCCESS;
		}
		
		public Pacient getPacient() {
			return pacient;
		}

		public void setPacient(Pacient pacient) {
			this.pacient = pacient;
		}
		
		@Override
		public Pacient getModel() {
			return this.pacient;
		}

		public HttpServletRequest getRequest() {
			return request;
		}

		@Override
		public void setServletRequest(HttpServletRequest request) {
			this.request = request;
		}

		@Override
		public void setServletResponse(HttpServletResponse response) {
			this.response = response;
		}
		
		public HttpServletResponse getResponse(){
			return this.response;
		}
}